package com.demo.apparel.service.uniapp.Impl;

import com.demo.apparel.entity.OrderItem;
import com.demo.apparel.mapper.uniapp.OrderItemMapper;
import com.demo.apparel.service.uniapp.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderItemServiceImpl implements OrderItemService {

    @Autowired
    private OrderItemMapper orderItemMapper;

    /**
     * 根据订单ID查询所有订单商品
     * @param orderId 订单ID
     * @return 订单商品列表
     */
    @Override
    public List<OrderItem> getOrderItemsByOrderId(String orderId) {
        return orderItemMapper.selectByOrderId(orderId);
    }

    /**
     * 插入订单商品
     * @param orderItem 订单商品对象
     * @return 插入的订单商品
     */
    @Override
    public OrderItem insertOrderItem(OrderItem orderItem) {
        orderItemMapper.insert(orderItem);
        return orderItem;
    }
}
